package com.example.springboot.Control.Impl;

import com.example.springboot.Control.DeptController;
import com.example.springboot.JaveBean.Dept;
import com.example.springboot.JaveBean.Result;
import com.example.springboot.JaveBean.User;
import com.example.springboot.Servies.Impl.DeptSerivesImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:DeptControllerImpl
 * @Date:2025/4/1 10:15
 */
//@RestController
@Controller
@ResponseBody
public class DeptControllerImpl implements DeptController {
    @Autowired
    DeptSerivesImpl deptServies;

    @GetMapping("/addinfo")
    @Override
    public String addController() {
        String s = deptServies.addDeptServies("添加数据啦!");
        return s;
    }

    @GetMapping("/awm")
    public Result list() {
        return Result.success(deptServies.selectAllServices());
    }

    @GetMapping("/awn1/{id}")
    public Result listone(@PathVariable Integer id) {
        return Result.success(deptServies.selectOneServices(id));
    }

    @DeleteMapping("/dept/{id}")
    public Result deleteOne(@PathVariable Integer id) {
        deptServies.deleteOneServices(id);
        return Result.success();
    }

    @PostMapping("/depts")
    public Result insertOne(@RequestBody Dept dept) {
        deptServies.insertOneServices(dept);
        return Result.success();
    }


    @PutMapping("/depts")
    public Result updateOne(@RequestBody Dept dept){
        deptServies.updateOneServices(dept);
        return Result.success();
    }


    @PostMapping("/login")
    public Result login(@RequestBody User user){
        return Result.success(deptServies.loginServices(user));
    }

}
